var express =require('express');
var router =express.Router();
var multiparty =require('multiparty');
var fs =require('fs');
const { compileClient } = require('jade');
router.get('/',function(req,res,next){
    console.log(__dirname);
    res.sendFile(__dirname.substring(0,__dirname.lastIndexOf('\\'))+'./view/index.html');
});
router.post('/',function(req,res){
    var from =new multiparty.Form();
    form.encoding='utf-8';
    from.uploadDir='./public/files';
    form.maxFilesSize=20*1024*1024;
    form.parse(req,function(err,fields,files){
        // var filesTemp=JSON.stringify(files,null,2);
        console.log(fields);
        console.log(files);
        if(err)throw err;
        var inputFile =files.uploadFile[0];
        var uploadedPath =inputFile.path;
        var destPath='./public/files'+inputFile.originalFilename;
        res.end();
    });
});
module.exports=router;